﻿@section header{

}
<partial name="_page_list" />
@section scripts{
    <script>
        $(function () {
            gridList();
        })
        function gridList() {
            $("#gridList").dataGrid({
                treeGrid: true,
                treeGridModel: "adjacency",
                hoverrows: false,
                gridview: true,
                mtype: "POST",
                url: "/rbac/ItemsType/GetTreeGridJson",
                height: $(window).height() - 90,
                colModel: [
                    { label: "主键", name: "ID", hidden: true, key: true },
                    { label: '名称', name: 'Name', width: 200, align: 'left' },
                    { label: '编号', name: 'EnCode', width: 150, align: 'left' },
                    { label: '排序', name: 'OrderBy', width: 80, align: 'center' },
                    {
                        label: "有效", name: "Status", width: 60, align: "center",
                        formatter: function (cellvalue) {
                            return cellvalue == true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                        }
                    },
                    { label: "备注", name: "Description", index: "Description", width: 200, align: "left" }
                ],
                rowNum: 20,
                rowList: [20, 50, 100],
                pager: '#gridPager',
                sortname: 'OrderBy',
                sortorder: "asc",
                viewrecords: true,
                autowidth: true,
                multiselect: true,
                loadComplete: function () {
                    $('.ui-jqgrid-bdiv').scrollTop(0);
                    setTimeout(function () { btn_tc(); });
                }
            });
        }
        function btn_add() {
            $.modalOpen({
                id: "Form",
                title: "新增分类",
                url: "/rbac/ItemsType/Form",
                width: "450px",
                height: "380px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        function btn_edit() {
            var keyValue = $("#gridList").jqGridRowValue().F_Id;
            $.modalOpen({
                id: "Form",
                title: "修改分类",
                url: "/rbac/ItemsType/Form?keyValue=" + keyValue,
                width: "450px",
                height: "380px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        function btn_delete() {
            $.deleteForm({
                url: "/rbac/ItemsType/DeleteForm",
                param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
                success: function () {
                    $("#gridList").resetSelection();
                    $("#gridList").trigger("reloadGrid");
                }
            })
        }
        function btn_details() {
            var keyValue = $("#gridList").jqGridRowValue().F_Id;
            $.modalOpen({
                id: "Details",
                title: "查看分类",
                url: "/rbac/ItemsType/Details?keyValue=" + keyValue,
                width: "450px",
                height: "510px",
                btn: null,
            });
        }
    </script>
}